package com.ruoyi.common.utils;

import java.util.Random;

public class AppUserAgentGenerator {

    // 常见的操作系统版本，包括小版本
//    private static final String[] IOS_VERSIONS = {
//            "15.0", "15.1", "15.1.1", "15.2", "15.3", "15.3.1", "15.4", "15.4.1", "15.5", "15.6", "15.7",
//            "16.0", "16.1", "16.2", "16.3", "16.4", "16.5",
//            "17.0", "17.1", "17.2", "17.3"
//    };

    // iPhone 10及其后的所有设备型号，包括Pro、Pro Max和SE
    private static final String[] IOS_DEVICES = {
            "iPhone10,1", "iPhone10,2", "iPhone10,3", "iPhone10,4", "iPhone10,5", // iPhone 8, 8 Plus, X
            "iPhone11,8", "iPhone11,2", "iPhone11,4", "iPhone11,6", // iPhone XR, XS, XS Max
            "iPhone12,1", "iPhone12,3", "iPhone12,5", // iPhone 11, 11 Pro, 11 Pro Max
            "iPhone12,8", // iPhone SE (2nd generation)
            "iPhone13,1", "iPhone13,2", "iPhone13,3", "iPhone13,4", // iPhone 12 mini, 12, 12 Pro, 12 Pro Max
            "iPhone14,4", "iPhone14,5", "iPhone14,2", "iPhone14,3", // iPhone 13 mini, 13, 13 Pro, 13 Pro Max
            "iPhone14,6", // iPhone SE (3rd generation)
            "iPhone15,2", "iPhone15,3", "iPhone15,4", "iPhone15,5" // iPhone 14, 14 Pro, 14 Pro Max
    };

    private static final Random RANDOM = new Random();

    public static String getRandomIOSUserAgent() {
        // 随机选择操作系统版本和设备型号
        String iosVersion = IOSVersionInfo.getRandomVersion().getIosVersion();
        String iosDevice = IOS_DEVICES[RANDOM.nextInt(IOS_DEVICES.length)];
        return String.format("Mozilla/5.0 (iPhone; CPU iPhone OS %s) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/ (iOS %s; %s)",
                iosVersion, iosVersion, iosDevice);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) { // 生成10个随机User-Agent作为示例
            System.out.println(getRandomIOSUserAgent());
        }
    }
}
